var express = require("express")
var router = express.Router()

const { person_infoModel } = require("../db/personinfo_model")

router.get('/person_info', async (req, res) => {
    let data = await person_infoModel.find()
    res.send({
        data,
        mes: "获取成功"
    })
})

router.put('/resume/:_id', async (req, res) => {
    const id = req.params._id
    const datas = req.body
    const data = await person_infoModel.updateOne({ _id: id }, { $set: datas })
    res.send({ data })
});

router.get('/get_info/:_id', async (req, res) => {
    const datas = req.params._id
    const data = await person_infoModel.find({ _id: datas })
    res.send({ data })
});

router.put("/delpeople/:_id", async (req, res) => {
    const id = req.params._id
    const data = await person_infoModel.findByIdAndDelete({
        _id: id
    })
    res.send({ data })
})
router.put("/delpeople/:_id", async (req, res) => {
    const id = req.params._id
    const data = await person_infoModel.findByIdAndDelete({
        _id: id
    })
    res.send({ data })
})

router.put("/addpeople", async (req, res) => {
    const data = req.body
    console.log(data, '234')
    await person_infoModel.create(data)
    res.send({ data })
})
module.exports = router;